/*
* Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Button.qml.
*/

import QtQuick 1.0

/*!
 *  \file
 *  \brief Button component for common use.
 *
 *  Defines a button component.
 */

Rectangle {
    id: button

    width: parent.width / 2 - 2 * margin
    height: parent.height - 2 * margin
    y: margin
    border.color: "cadetblue"
    border.width: 2

    gradient: Gradient {
        GradientStop { position: 0.0; color: mouseArea.pressed ? "white" : "lightsteelblue" }
        GradientStop { position: 1.0; color: mouseArea.pressed ? "lightblue" : "gray" }
    }

    opacity: 1.0
    radius: margin

    signal buttonClicked()
    property string label: "default text"
    property int margin: 5

    Text {
        id: buttonText
        anchors.centerIn: parent
        text: button.label
        font.pixelSize: 25
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent;
        onPressed: {
            color = "lightblue"
            // Provide tactile feedback.
            pressEffect.play();
        }
        onReleased: {
            color = "lightgray"
            // Provide tactile feedback and emit signal.
            releaseEffect.play()
            buttonClicked();
        }
    }
}


